package com.imooc.uua.rest;

import lombok.Data;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * UserResource
 * </p>
 *
 * @author flyduck
 * @since 2023/12/14
 */
@RestController
@RequestMapping("/api")
public class UserResource {

    @GetMapping("greeting")
    public String greeting(){
        return "Hello World";
    }

    @PostMapping("greeting")
    @ResponseStatus(HttpStatus.CREATED)
    public String makeGreeting(@RequestParam String name,@RequestBody Profile profile){
        return "Hello World，" + name + "!\n" + profile.gender;
    }

    @PutMapping("greeting/{name}")
    public String putGreeting(@PathVariable String name){
        return "Hello World，" + name;
    }

    @Data
    static class Profile{
        private String gender;
        private String idNo;
    }
}
